/**
 * zmn 花名册模块-产品组
 * @author tanghongjun
 * @since 2020-08-19 11:18:36
 */
let flag = true;
layui.define(['index', 'form', 'table', 'laypage', 'layedit'], function (exports) {
    var $ = layui.$;
    var form = layui.form;

    form.render(null, "zmn-form");

    // 提交
    form.on('submit(zmn-form-submit)', function(obj){
        var data = obj.field;
        var url = "/product/businessline/addEdit.action";

        if(data.groupId > 0){
            flag = false;
        }

        $.ajax({
            async: false,
            type: "POST", url: url,
            contentType: "application/json", dataType: "json", data: JSON.stringify(data),
            success:function(result) {
                if(result.status == 200) {
                    layui.layer.msg(result.message,{time: 1000},()=>{
                        zmnLayUtil.closeThisIframeMsg(parent, result.message, "zmn-table");
                        parent.location.reload();
                    });
                } else {
                    layui.layer.msg(result.message,{"icon":2});
                }
            },
            error:function(XMLHttpRequest, textStatus, errorThrown){
            }
        })
        return false;
    });
    //对外暴露的接口
    exports('plat_businessline_detail', {});
});

// 取消
function cancel() {
    let index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
    parent.layer.close(index);
}